package co.edu.uniandes.webdesktop.chat.client.interfaz;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.ToolButton;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.extjs.gxt.ui.client.widget.tree.Tree;
import com.extjs.gxt.ui.client.widget.tree.TreeItem;


public class VentanaAmigos extends Window
{
	public VentanaAmigos()
	{
	this.setCloseAction(CloseAction.HIDE);
	this.setMinimizable(true);
	this.setMaximizable(true);
	this.setIconStyle("accordion");
	this.setHeading("Amigos Conectados");
	this.setWidth(200);
	this.setHeight(350);

	ToolBar toolBar = new ToolBar();
	TextToolItem item = new TextToolItem();
	item.setIconStyle("icon-connect");
	toolBar.add(item);
	toolBar.add(new SeparatorToolItem());
	this.setTopComponent(toolBar);

	item = new TextToolItem();
	item.setIconStyle("icon-user-add");
	toolBar.add(item);

	item = new TextToolItem();
	item.setIconStyle("icon-user-delete");
	toolBar.add(item);

	this.setLayout(new AccordionLayout());

	ContentPanel cp = new ContentPanel();
	cp.setHeading("Usuarios Conectados");
	cp.setScrollMode(Scroll.AUTO);
	cp.getHeader().addTool(new ToolButton("x-tool-refresh"));

	this.add(cp);

	Tree tree = new Tree();
	TreeItem family = new TreeItem("Familia");
	tree.getRootItem().add(family);
	family.add(newItem("Camila", "user-girl"));
	family.add(newItem("Pablo", "user-kid"));
	family.setExpanded(true);

	TreeItem friends = new TreeItem("Novasoft");
	tree.getRootItem().add(friends);
	friends.add(newItem("Manuel", "user"));
	friends.add(newItem("Nicolas", "user"));
	friends.add(newItem("Marco", "user"));
	friends.add(newItem("Daniel", "user"));
	friends.add(newItem("Jose", "user"));
	friends.setExpanded(true);

	cp.add(tree);

	cp = new ContentPanel();
	cp.setHeading("Opciones");
	cp.setBodyStyleName("pad-text");
	this.add(cp);

	cp = new ContentPanel();
	cp.setHeading("Extras");
	cp.setBodyStyleName("pad-text");
	this.add(cp);

	}
	
	/**
	 * Crea un nuevo item para el Tree
	 * @param text
	 * @param iconStyle
	 * @return
	 */
	private TreeItem newItem(String text, String iconStyle) {
		TreeItem item = new TreeItem(text);
		item.setIconStyle(iconStyle);
		return item;
	}
}
